package com.kuangstudy.io.demo;

import java.io.File;
import java.io.IOException;

/**
 * ClassName: Demo5
 * date: 2021/07/15 16:27:50
 *
 * @author zlk
 */
public class Demo5 {
    public static void main(String[] args) {
        show3();
    }

    /**
     * delete() 删除文件/文件夹
     */
    private static void show3() {
        File file = new File("e:\\BBB\\AAA\\CCC\\DDD");
        File file1 = new File("e:\\1.txt");
        System.out.println(file.delete());
        System.out.println(file1.delete());
    }

    /**
     * createNewFile 只能创建文件
     */
    public static void show1(){
        File file = new File("e:\\1.txt");
        File file1 = new File("2.txt");
        if (file.exists()){
            file.delete();
        }
        try {
            boolean newFile = file.createNewFile();
            System.out.println(newFile);
            System.out.println(file1.createNewFile());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * mkdir()创建单级文件夹
     * mkdirs()创建多级文件夹
     */
    public static void show2(){
        File dir = new File("e:\\BBB\\AAA\\CCC\\DDD");
        boolean mkdirs = dir.mkdirs();
        System.out.println(mkdirs);

    }
}
